package edu.hunau.cxb19.oop.class30;

/**
 *
 * @author hb
 *
 *         2020-04-14 15:26:59
 */
public class ThreadYieldTest {

	public static void main(String[] args) {
		Thread t1 = new Thread(() -> {
			for (int i = 0; i < 100; i++) {
				System.out.println(Thread.currentThread().getName() + " :i=" + i);
			}
		}, "my-thread-A");

		Thread t2 = new Thread(() -> {
			for (int i = 0; i < 100; i++) {
				System.out.println(Thread.currentThread().getName() + " :i=" + i);
				if (i == 20) {
					System.out.println("------yield------");
					Thread.yield();
				}
			}
		}, "\tmy-thread-B");
		t2.setPriority(Thread.MAX_PRIORITY);
		
		t1.start();
		t2.start();
	}
}
